package com.xhdx.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class TestArryList {

    public static void main(String[] args) {
        final int count = 20 * 100000;
        List<Integer> list = new ArrayList<>();
        long begin = System.currentTimeMillis();
        for(int i = 0; i < count ; i++) {
            list.add(i);
        }
        System.out.println("没有设置ArrayList初始容量： " + (System.currentTimeMillis() - begin) + " ms");
        
        list = new ArrayList<>(count);
        begin = System.currentTimeMillis();
        for(int i = 0; i < count ; i++) {
            list.add(i);
        }
        System.out.println("设置了ArrayList初始容量： " + (System.currentTimeMillis() - begin) + " ms");
        Collections.synchronizedMap(new HashMap<Object,Object>());

    }

}
